//  Inside Microsoft Exchange 2007 Web Services
//  Chapter 6
//
//  Copyright (c) 2007 David Sterling, Ben Spain, Mark Taylor, Huw Upshall, Michael Mainer.
//  All rights reserved.
//
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Xml;
using System.IO;
using ProxyHelpers.EWS;

namespace SetCompleteName
{
    class Program
    {
        static void Main(string[] args)
        {
            ExchangeServiceBinding binding = new ExchangeServiceBinding();
            binding.Url = @"https://yourServer/ews/Exchange.asmx";
            binding.Credentials = new NetworkCredential(
                "username",
                "password",
                "domain");

            // First create a contact so we can change its complete name
            //
            ContactItemType myContact = new ContactItemType();
            myContact.DisplayName = "My Name";
            ItemIdType myContactId = EWSHelpers.CreateItem(binding, myContact);
            
            // Set up our complete name
            //
            CompleteNameType completeName = new CompleteNameType();
            completeName.FirstName = "New First Name";
            completeName.LastName = "New Last Name";

            // Call our "SetCompleteName" helper method
            //
            ItemInfoResponseMessageType response = ContactItemType.SetCompleteName(
                        binding, myContactId, completeName);
        }
    }
}
